package cn.jaychang.demo.auth.server.userdetails;

import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

/**
 * 扩展UserDetailsService接口功能
 * 使得可以支持按手机号、按openid来获取UserDetails
 *
 * @author jaychang
 */
public interface ExtUserDetailsService extends UserDetailsService {

    /**
     * 根据手机号加载用户信息
     *
     * @param username
     * @return
     * @throws UsernameNotFoundException
     */
    UserDetails loadUserByMobile(String mobile) throws UsernameNotFoundException;

    /**
     * 根据手机号加载用户信息(若无此认证方式，则实现类无需实现该方法)
     *
     * @param openid
     * @return
     * @throws UsernameNotFoundException
     */
    default UserDetails loadUserByOpenid(String openid) throws UsernameNotFoundException {
        return null;
    }
}
